package com.cheng.operation.impl;

import com.cheng.common.exception.CommonException;
import com.cheng.data.entity.CompanyBaseInfoEntity;
import com.cheng.data.vo.CompanyBaseInfoVO;
import com.cheng.operation.CompanyBaseInfoOperation;
import com.cheng.service.CompanyBaseInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: ChengJW
 * @date: 2021/11/7 21:55
 * @version: 1.0
 * @description: 有关企业基本信息表 companyBaseInfo 的业务逻辑处理
 */
@Service
public class CompanyBaseInfoOperationImpl implements CompanyBaseInfoOperation {

    private final static Logger log = LoggerFactory.getLogger(CompanyBaseInfoOperationImpl.class);

    @Autowired
    private CompanyBaseInfoService companyBaseInfoService;


    /**
    * @author: ChengJW
    * @params: [entity]
    * @return: com.cheng.data.vo.CompanyBaseInfoVO
    * @date: 2021/11/7
    * @description: 查询 companyBaseInfo 信息
    */
    @Override
    public CompanyBaseInfoEntity queryCompanyBaseInfo(CompanyBaseInfoEntity entity) throws CommonException {

        List<CompanyBaseInfoEntity> list = companyBaseInfoService.queryCompanyBaseInfo(entity);
        CompanyBaseInfoEntity companyBaseInfoEntity = null;
        if (null != list && list.size() > 0){
            companyBaseInfoEntity = list.get(0);
        }
        return companyBaseInfoEntity;
    }

    /**
     * @author: ChengJW
     * @params: [entity]
     * @return: com.cheng.data.vo.CompanyBaseInfoVO
     * @date: 2021/9/20
     * @description: 根据条件查询一条 companyBaseInfo 信息，并返回VO
     */
    @Override
    public CompanyBaseInfoVO selectOneCompanyInfo(CompanyBaseInfoEntity entity) throws CommonException {

        CompanyBaseInfoVO vo = new CompanyBaseInfoVO();
        List<CompanyBaseInfoEntity> list = companyBaseInfoService.queryCompanyBaseInfo(entity);
        if (null != list && list.size() > 0){
            BeanUtils.copyProperties(list.get(0),vo);
            return vo;
        }
        return null;
    }
}
